$(document).ready(function(){
  $('#ddlcountry').live('change', function() {
    if($(this).val().length != 0) {
			var id = $(this).val();
            $.ajax({
                type: 'GET',
                url: '../trainees/get_cities_ajax',
                data: "countryId=" + id,
				dataType:"json",
                success: populateCityList, context:this
            });
			}
        });
		
	$('#txtpw1').live('focusout', function() {
			var pw = $("#txtpw").val();
			var pw1 = $("#txtpw1").val();
			if(pw != pw1)
			{
				$('#errormsg').hide();
				var msg = 'Password does not match';
				$('input[type=submit]').attr("disabled", "disabled");
			}
			else
			{
				var msg = '';
				$('input[type=submit]').attr("disabled", "");
			}
			$("#errormsg").html("<span style='font-size:11px; font-family: Tahoma; color:#FF0000'>" + msg + "</span>").show();
        });
    
 
});
 
function populateCityList(response, status) {
  var options = '<option>-- Select city --</option>';
  $.each(response, function(index, name) {
    options += '<option value="' + index + '">' + name + '</option>';
  });
  $('#ddlcity').html(options);
  $('#cities').show();
 
}